#include <bits/stdc++.h>
using namespace std;

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = INT_MAX;
    sort(a.begin(), a.end());
    for(int i = 0; i < n - 1; i++){
        int t = a[i] + a[i + 1];
        int p = lower_bound(a.begin(), a.end(), t) - a.begin();
        ans = min(ans, n - p + i);
    }
    cout << ans << endl;
}

int main(){
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}